package com._54programer.http.initializer;

import com._54programer.http.handler.HttpServerHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class HttpServerInitializer extends ChannelInitializer<SocketChannel> {
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //得到一个管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //向管道中加入处理器
        //http的编解码器
        pipeline.addLast("httpServerCodec", new HttpServerCodec());
        //自定义handler
        pipeline.addLast("", new HttpServerHandler());
    }
}
